#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75586-make.sh
# Version:    1.0
# Date:       2014/07/10
# Author:     jinzhao.wang
# Email:      jinzhao.wang@cs2c.com.cn
# Summary:    02系统基本功能-07开发环境-09make构建工具
# Notes:      make构建工具
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/02
#             -   The first one
#             Version 1.1, 2014/11/24
#             -   The second one;
#             -   Add SFROOT;
# ----------------------------------------------------------------------
if [ -z "$SFROOT" ]
then
    CMDLIB=./
    SFROOT=./
else
    CMDLIB=${SFROOT}/testcases/Development_Environment
fi

. ${SFROOT}/lib/Echo.sh
. ${SFROOT}/lib/XmlParse.sh



function CleanData ()
{
  rm -rf Makefile
  EchoInfo "75586-make.sh执行完毕"
}

trap "CleanData" EXIT INT

#编写makefile
echo "all:test1 test2" > Makefile
echo "test1:" >> Makefile
echo -e '\techo "test1" >test1.txt' >> Makefile
echo "test2:" >> Makefile
echo -e '\techo "test2" >test2.txt' >> Makefile
echo "clean:" >> Makefile
echo -e "\trm -rf test1.txt" >> Makefile
echo -e "\trm -rf test2.txt" >> Makefile
cat Makefile
make all
[ -f "test1.txt" ] && [ -f "test2.txt" ]
EchoResult "成功生成test1.text和test2.txt文件"
test  "`cat test1.txt`" == "test1"  
EchoResult "test1.txt文件内容为test1"
test  "`cat test2.txt`" == "test2"  
EchoResult "test2.txt文件内容为test2"
# make clean
make clean
[ ! -f "test1.txt" ] && [ ! -f "test2.txt" ]
EchoResult "成功删除test1.text和test2.txt文件"


